import React, { Component } from 'react'
import Son from './Son'
import Grandson from './Grandson'
import styles from './assemble.module.css'
import {  Button } from 'antd'
import One from './ReduxdomeOne'
import Two from './ReduxdomeTwo'

export const ThemeContext  = React.createContext('默认值');

export default class Parent extends Component {
    constructor(){
        super()
        this.state = {
            msg:'父亲',
            parentData:'这是一个寂寞的天'
        }
        
    }

    changeData =() =>{
        this.setState({
            parentData:'君不见,黄河之水天上来' + Math.random() * 100
        })
    }
    // 跨级传参

    
    render() {
        return (
            <div className={styles.parent}>
               
                 <ThemeContext.Provider value={this.state.parentData}>
                    <Son></Son>
                    <Grandson></Grandson>
                 </ThemeContext.Provider>
                
                <Button  className={styles.btn} type='primary' onClick= {this.changeData } >修改数据</Button>
                <div className={styles.redux_dome}>
                   <One/>
                   <Two/>
                </div>
            </div>
        )
    }
}

